import {
  archive
} from '../../api/blog'

Component({
  pageLifetimes: {
    show() {
      if (typeof this.getTabBar === 'function' &&
        this.getTabBar()) {
        this.getTabBar().setData({
          selected: 1
        })
      }
    }
  },
  data: {
    list: [],
    sk: true
  },
  attached: function () {
    archive().then(res => {
      this.setData({
        list: res,
        sk: false
      })
    })
  },
  methods: {
    toList(e) {
      wx.navigateTo({
        url: `/pages/list/index?month=${e.currentTarget.dataset.month}`
      })
    }
  }
})